<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8"%>
<jsp:useBean id="pageBean" scope="request" class="com.agileai.hotweb.domain.PageBean"/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>数据库操作拦截器设置</title>
<%@include file="/jsp/inc/resource.inc.jsp"%>
<script language="javascript">
function setupOperaType(isSyn){
	if (isSyn == 'false'){
		$('#operaTypeTr').hide();
	}
	else if (isSyn == 'true'){
		$('#operaTypeTr').show();		
	}
}
function saveInterceptorCfg(){
	var obj = ele('isSynchronous2');
	if (obj.checked){
		if (validation.checkNull($('#variableCode').val())){
			writeErrorMsg('变量返回值不能为空！');
			return;
		}
	}
	postRequest('form1',{actionType:'save',onComplete:function(rspText){
		if ("success" == rspText){
			parent.refreshInterceptor();
			parent.PopupBox.closeCurrent();
		}else{
			alert(rspText);
		}
	}});
}
</script>
</head>
<body>
<form action="<%=pageBean.getHandlerURL()%>" name="form1" id="form1" method="post">
<%@include file="/jsp/inc/message.inc.jsp"%>
<table class="detailTable" cellspacing="0" cellpadding="0">
<tr>
	<th width="100" nowrap>拦截器名称</th>
	<td><input id="interceptorName" label="拦截器名称" name="interceptorName" type="text" value="<%=pageBean.inputValue("interceptorName")%>" size="24" class="text" />
</td>
</tr>
<tr>
	<th width="100" nowrap>拦截器类型</th>
	<td><input name="interceptorTypeName" label="拦截器类型" type="text" class="text" id="interceptorTypeName" value="<%=pageBean.selectText("interceptorTypeSelect",pageBean.inputValue("interceptorType"))%>" size="24" readonly="readonly" /><input name="interceptorType" type="hidden" id="interceptorType" value="<%=pageBean.inputValue("interceptorType")%>" />
</td>
</tr>
<tr>
	<th width="100" nowrap>数据库连接</th>
	<td nowrap="nowrap"><input label="数据库连接" name="dataSourceCode" type="text" class="text" id="dataSourceCode" value="<%=pageBean.inputValue("dataSourceCode")%>" size="24" readonly="readonly" />
    <input type="button" name="button5" id="button5" value="选择" onclick="doSubmit({actionType:'selectDBLink',doValidate:'false'})" />
    <input type="button" name="button" id="button" value="添加" onclick="doSubmit({actionType:'addDBLink',validation:'false'})" /></td>
</tr>
<tr>
	<th width="100" nowrap>SQL</th>
	<td><textarea onKeydown="savePos(this)" onKeyup="savePos(this)" onmousedown="savePos(this)" onmouseup="savePos(this)" onfocus="savePos(this)" label="SQL" name="sqlTemplate" cols="53" rows="8"  class="textarea" id="sqlTemplate"><%=pageBean.inputValue("sqlTemplate")%></textarea><img class="varselecter" src="images/varselecter.png" width="20" height="20" onclick="showVariableBox('sqlTemplate')" style="cursor:pointer" />
</td>
</tr>
<tr>
	<th width="100" nowrap>操作类型</th>
	<td><input  onclick="setupOperaType(this.value)" name="isSynchronous" type="radio" id="isSynchronous1" value="false" <%=pageBean.checked("false".equals(pageBean.inputValue("isSynchronous"))) %>  />
	异步&nbsp;&nbsp; &nbsp;&nbsp; 
	<input type="radio" onclick="setupOperaType(this.value)" name="isSynchronous" id="isSynchronous2" value="true" <%=pageBean.checked("true".equals(pageBean.inputValue("isSynchronous"))) %> />
同步</td>
</tr>
<tr id="operaTypeTr">
	<th width="100" nowrap>返回值变量</th>
	<td><textarea name="variableCode" cols="53" rows="1" class="text" id="variableCode"><%=pageBean.inputValue("variableCode")%></textarea>	  <img class="varselecter" src="images/varselecter.png" width="20" height="20" onclick="showVariableBox('variableCode')" style="cursor:pointer" />
    </td>
</tr>
</table>
<input type="hidden" name="actionType" id="actionType" value=""/>
<input type="hidden" id="WFA_ID" name="WFA_ID" value="<%=pageBean.inputValue("WFA_ID")%>" />
<input type="hidden" id="positionType" name="positionType" value="<%=pageBean.inputValue("positionType")%>" />
<input type="hidden" id="interceptorId" name="interceptorId" value="<%=pageBean.inputValue("interceptorId")%>" />
<div style="text-align:center">
<input type="button" class="formbutton" name="button5" id="button5" value="保存" onclick="saveInterceptorCfg()" />
&nbsp;&nbsp;
<input type="button" class="formbutton" name="button" id="button" value="上一步" onclick="goToBack()" <%=pageBean.disabled(pageBean.isValid(pageBean.inputValue("interceptorId")))%> />
&nbsp;&nbsp;
<input type="button" class="formbutton" name="button" id="button" value="取消" onclick="javascript:parent.PopupBox.closeCurrent();" />
<jsp:include page="/jsp/inc/varselecter.inc.jsp" flush="true" />
</div>
</form>
</body>
</html>
<script language="javascript">
setupOperaType('<%=pageBean.inputValue("isSynchronous")%>');
requiredValidator.add("interceptorName");
requiredValidator.add("dataSourceCode");
requiredValidator.add("sqlTemplate");
</script>
<%@include file="/jsp/inc/scripts.inc.jsp"%>
